<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<link rel="stylesheet" href="./static/layui/css/layui.css">
	</head>
	<body>
		<form class="layui-form" method="post" action="goodsupdate.do">
			<div class="layui-form-item" hidden>
				<label class="layui-form-label" >id</label>
				<div class="layui-input-block">
					<input type="text" name="id" lay-verify="title" autocomplete="off" placeholder="请输入用户名"
						   class="layui-input"  value="${goods.id}">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">物品名称</label>
				<div class="layui-input-block">
					<input type="text" name="goodname" lay-verify="title" autocomplete="off" placeholder="请输入物品名称"
						class="layui-input" value="${goods.goodname}">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">所属分类</label>
				<div class="layui-input-block">

					<select name="catename" lay-filter="aihao" id="cate1" >
						<option value="0">请选择</option>
						<c:forEach items="${requestScope.cates}" var="c">
						<c:choose>
							<c:when test="${c.catename eq goods.catename}">
								<option value="${c.catename}" selected>${c.catename}</option>
							</c:when>
							<c:otherwise>
								<option value="${c.catename}">${c.catename}</option>
							</c:otherwise>
						</c:choose>

<%--							<option value="${c.catename}">${c.catename}</option>--%>
						</c:forEach>
					</select>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">价格</label>
				<div class="layui-input-block">
					<input type="number" name="price" lay-verify="title" autocomplete="off" placeholder="请输入价格"
						class="layui-input" value="${goods.price}">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">所属用户</label>
				<div class="layui-input-block">
<%--					<input type="text" name="username" lay-verify="title" autocomplete="off" placeholder="请输入用户名"--%>
<%--						class="layui-input">--%>
						<select name="username" lay-filter="aihao" id="cate">
							<option value="0">请选择</option>
							<c:forEach items="${users}" var="u">
								<c:choose>
									<c:when test="${u.username eq goods.username}">
										<option value="${u.username}" selected>${u.username}</option>
									</c:when>
									<c:otherwise>
										<option value="${u.username}">${u.username}</option>
									</c:otherwise>
								</c:choose>
<%--								<option value="${u.username}">${u.username}</option>--%>
							</c:forEach>
						</select>
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
	</body>
	<!-- <script type="text/javascript" src="../../js/vue.js" charset="utf-8"></script> -->
	<script type="text/javascript" src="./static/layui/layui.js"></script>
	<script type="text/javascript" src="./static/js/jquery-3.4.1.min.js"></script>
	<script>
		// layui.use(['form', 'layedit', 'laydate'], function() {
		// 	var form = layui.form,
		// 		layer = layui.layer,
		// 		layedit = layui.layedit,
		// 		laydate = layui.laydate;
		//
		// 	//日期
		// 	laydate.render({
		// 		elem: '#date'
		// 	});
		// 	laydate.render({
		// 		elem: '#date1'
		// 	});
		//
		// 	//创建一个编辑器
		// 	var editIndex = layedit.build('LAY_demo_editor');
		//
		// 	//监听提交
		// 	// form.on('submit(demo1)', function(data) {
		// 	// 	var g = data.field;
		// 	// 	$.post("http://121.196.194.191:8082/saveGoods.action", {
		// 	// 			goodsname: g.goodsname,
		// 	// 			cate: g.cate,
		// 	// 			price: g.price,
		// 	// 			uId: g.uId
		// 	// 		},
		// 	// 		function(data) {
		// 	// 			if (data.status == "200") {
		// 	// 				window.location.href = "goodslist.html";
		// 	// 			} else {
		// 	// 				alert("添加用户失败")
		// 	// 			}
		// 	// 		}
		// 	// 	)
		// 	//
		// 	// 	return false;
		// 	// });
		// });
	</script>
	<script>
		function ja() {
			var ct = document.getElementById("cate");
			console.log(ct)
			// $.ajaxSettings.async = false;
			// $.post(
			// 	"http://121.196.194.191:8082/queryCateAll.action",
			// 	function(data) {
			// 		var cate = data.cates;
			// 		// ct.innerHTML=`<select name="cataId" lay-filter="aihao" id="cate">
			// 		//        <option value="0">请选择</option>
			// 		//      </select>`;
			// 		// var option = document.createElement('p');
			// 		for (var i in cate) {
			// 			ct.innerHTML += `<option value='` + cate[i].id + `'>` + cate[i].catename + `</option>`
			// 			// ct.appendChild(option);
			// 		}
			//
			// 	})
			// // console.log(ct)
			// }
			// ja();
	</script>
	<!-- 	<script type="text/javascript">
		$.ajax({
			url:"http://121.196.194.191:8082/queryCateAll.action",
			type:"post",
			success:function(data){
				var cate = data.cates;
				var ct = document.getElementById("cate");
				
			}
		})
	</script> -->
</html>
